home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_1599 / 1430 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  4.1 KB

  1. From: itschere@techfak.uni-bielefeld.de
  2. Date: Sun, 22 May 94 16:46:33 +0200
  3. Message-Id: <9405221446.AA04421@pirol.techfak.uni-bielefeld.de>
  4. To: mint@atari.archive.umich.edu
  5. Subject: MiNT 1.10 biosfs.c patch
  6.  
  7.  Hey you all!
  8.  
  9.  The 'old' Dcntl() function in biosfs.c didn't check for an already existing
  10. entry with the same name if you wanted to install a new device. Since the new
  11. device was linked into the chain at top position, it was at least guaranteed
  12. to be able to be opened in susequent open calls, but the old entry remained
  13. visible for directory listing. This version completely replaces an old entry,
  14. if it exists, and therefore makes directory listing looks much nicer... :-)
  15.  
  16.  Sorry, but I momentarily fail to have a working (good) version of diff, so
  17. if you like it, just take the following code and make it completely replace
  18. the old Dcntl() function in biosfs.c... ;-(
  19.  
  20.  I'm still thinking about a good way to make it more easier to replace the old
  21. device drivers, say, split the biosfs.c file into a real filesystem code plus
  22. several device driver codes and still being flexible enough so that one driver
  23. can install several devices (there wouldn't be a statically declared array of
  24. bios devices any more, or, at least, not ONE containing EVERY possible
  25. devices), but for the moment I think it's easier (and therefore better) to
  26. implement them as XDD's, and that's where I hope this patch comes handy...
  27.  
  28.  And I'd also like to wait for 1.11 before implementing this... :-)
  29.  
  30.  Any new rumours about it? ;-)
  31.  
  32. ciao,
  33. TeSche
  34. --
  35. Torsten Scherer (TeSche, Schiller...)
  36. Faculty of Technology, University of Bielefeld, Germany, Europe, Earth...
  37. | Use any of "finger itschere@129.70.131.2-15" for adresses and more.    |
  38. | Last updated: Probably yesterday.                    |
  39.  
  40. --- cut cut cut ---
  41.  
  42. static long ARGS_ON_STACK
  43. bios_fscntl(dir, name, cmd, arg)
  44.     fcookie *dir;
  45.     const char *name;
  46.     int cmd;
  47.     long arg;
  48. {
  49.     struct bios_file *b;
  50.     static int devindex = 0;
  51.  
  52.     if (curproc->euid) {
  53.         DEBUG(("biosfs: Dcntl() by non-privileged process"));
  54.         return ((unsigned)cmd == DEV_INSTALL) ? 0 : EACCDN;
  55.     }
  56.  
  57.     if (IS_FD_DIR(dir))
  58.         return EACCDN;
  59.  
  60.     /* ts: let's see if such an entry already exists */
  61.     for (b=broot; b; b=b->next)
  62.         if (!strcmp(b->name, name))
  63.             break;
  64.  
  65.     switch ((unsigned) cmd) {
  66.         case DEV_INSTALL: {
  67.             struct dev_descr *d = (struct dev_descr *)arg;
  68.  
  69.             if (!b) {
  70.                 b = kmalloc(SIZEOF(struct bios_file));
  71.                 if (!b)
  72.                     return 0;
  73.                 b->next = broot;
  74.                 broot = b;
  75.                 strncpy(b->name, name, BNAME_MAX);
  76.                 b->name[BNAME_MAX] = 0;
  77.             }
  78.             b->device = d->driver;
  79.             b->private = d->dinfo;
  80.             b->flags = d->flags;
  81.             b->tty = d->tty;
  82.             set_xattr(&(b->xattr), S_IFCHR|DEFAULT_MODE, UNK_RDEV|devindex);
  83.             devindex = (devindex+1) & 0x00ff;
  84.             return (long)&kernelinfo;
  85.         }
  86.         case DEV_NEWTTY:
  87.             if (!b) {
  88.                 b = kmalloc(SIZEOF(struct bios_file));
  89.                 if (!b)
  90.                     return ENSMEM;
  91.                 strncpy(b->name, name, BNAME_MAX);
  92.                 b->name[BNAME_MAX] = 0;
  93.                 b->tty = kmalloc(SIZEOF(struct tty));
  94.                 if (!b->tty) {
  95.                     kfree(b);
  96.                     return ENSMEM;
  97.                 }
  98.                 b->next = broot;
  99.                 broot = b;
  100.             } else {
  101.                 /*  ts: it's probably better to use a new tty
  102.                  * structure here, but don't touch the old
  103.                  * pointers until we know we've got enough
  104.                  * memory to do it!
  105.                  */
  106.                 struct tty *ttyptr;
  107.  
  108.                 if (!(ttyptr = kmalloc(SIZEOF(struct tty))))
  109.                     return ENSMEM;
  110.                 b->tty = ttyptr;
  111.             }
  112.             b->device = &bios_tdevice;
  113.             b->private = arg;
  114.             b->flags = O_TTY;
  115.             *b->tty = default_tty;
  116.             set_xattr(&(b->xattr), S_IFCHR|DEFAULT_MODE, BIOS_RDEV|(b->private&0x00ff));
  117.             return 0;
  118.  
  119.         case DEV_NEWBIOS: {
  120.             if (!b) {
  121.                 b = kmalloc(SIZEOF(struct bios_file));
  122.                 if (!b)
  123.                     return ENSMEM;
  124.                 b->next = broot;
  125.                 broot = b;
  126.                 strncpy(b->name, name, BNAME_MAX);
  127.                 b->name[BNAME_MAX] = 0;
  128.             }
  129.             /*  ts: it's probably better not to free an old tty
  130.              * structure here, cause we don't know if any process
  131.              * who didn't recognize this change is still using it.
  132.              */
  133.             b->tty = 0;
  134.             b->device = &bios_ndevice;
  135.             b->private = arg;
  136.             b->flags = 0;
  137.             set_xattr(&(b->xattr), S_IFCHR|DEFAULT_MODE, BIOS_RDEV|(b->private&0x00ff));
  138.             return 0;
  139.         }
  140.     }
  141.  
  142.     return EINVFN;
  143. }
  144.